package com.group3.pojo.result;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.group3.domain.PunchRecord;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * PunchRecordResult
 *
 * @author HY
 * 2021/06/07 16:49
 **/

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("打卡记录返回类")
public class PunchRecordResult {
    private Integer punchId;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date punchDate;

    @JsonFormat(pattern = "HH:mm:ss")
    private Date punchTime;

    public void setPunchTime(Date punchTime){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        this.punchTime = punchTime;
        try {
            this.punchDate = df.parse(df.format(punchTime));
        }catch (Exception e){
            return;
        }
    }

    @JsonFormat(pattern = "hh:MM:ss")
    private Date punchDayTime;

    public Date getPunchDayTime(Date punchDayTime) {
        return getPunchTime();
    }
}
